<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>系统通知</title>
    <script src="https://cdn.jsdelivr.net/npm/dayjs@1.10.7/dayjs.min.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" type="text/css" href="/assets/element-plus/index.css">
    <!-- 引入组件库 -->
    <script src="/assets/vue/vue.global.js"></script>
    <script src="/assets/element-plus/index.full.js"></script>
    <script src="/assets/axios/axios.js"></script>
    <script src="/assets/oa/security.js"></script>
</head>
<body>
<div id="app">
    <h2>系统通知</h2>
    <el-table
            ref="singleTable"
            :data="tableData"
            highlight-current-row
            style="width: 100%">
        <el-table-column
                property="index"
                label="序号"
                width="50">
        </el-table-column>
        <el-table-column
                property="createtime"
                label="通知时间"
                width="180">
        </el-table-column>

        <el-table-column
                property="content"
                label="通知内容">
        </el-table-column>
    </el-table>

</div>

<script>

    var Main = {
        data() {
            return {
                tableData: []
            }
        }
        ,mounted() {
            const objApp = this;
            axios.get("/notice/list")
                .then(function (response) {
                    console.log("Response data:", response.data); // 添加日志输出
                    if (response.data && response.data.data && Array.isArray(response.data.data)) {
                        objApp.tableData.splice(0, objApp.tableData.length);
                        response.data.data.forEach(function (item, index) {
                            // 使用day.js解析和格式化日期
                            var formattedDate = dayjs(item.createtime).format('YYYY-MM-DD HH:mm:ss');
                            item.createtime = formattedDate;
                            item.index = index + 1;
                            objApp.tableData.push(item);
                        });
                    } else {
                        console.error("Invalid response data:", response.data); // 添加日志输出
                    }
                })
                .catch(function (error) {
                    console.error("Request failed:", error); // 添加日志输出
                });
        }


    };
    const app = Vue.createApp(Main);
    app.use(ElementPlus);
    app.mount("#app")
</script>

</body>
</html>